﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPageMain.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="estudent.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="JQueryContent" runat="server">
    <script type="text/javascript">

        $(document).ready(function () {
            $("#vpisi").change(function () {
                $("#vpisi option[value='prazen']").hide();

                $.post("PrijavaIzpit/PoisciPredmete", $("#kriteriji").serialize(), function (data) {
                    $("#predmeti").html(data);

                });
            });

            $("#predmeti").change(function () {
                $("#predmeti option[value='prazen']").hide();

                $.post("PrijavaIzpit/PoisciRoke", $("#kriteriji").serialize(), function (data) {
                    $("#roki").html(data);

                });
            });

            //ce pritisnemo back button
            if ($("#vpisi").val() != "prazen" && $("#vpisi").val() != undefined) {
                $("#vpisi option[value='prazen']").hide();

                $.post("PrijavaIzpit/PoisciPredmete", $("#kriteriji").serialize(), function (data) {
                    $("#predmeti").html(data);

                });

                if ($("#predmeti").val() == "prazen") {

                    $.post("PrijavaIzpit/getSession", function (data) {

                        $("#predmeti").val(data);

                        //pocakajmo nekaj casa
                        setTimeout(function () {

                            $.post("PrijavaIzpit/PoisciRoke", $("#kriteriji").serialize(), function (data) {
                                $("#roki").html(data);

                            });

                        }, 1000);


                    });
                }
            }
        });

    </script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="InnerRightContent" runat="server">

    <h1>Prijava na izpit</h1>

<form action="PrijavaIzpit/Prijava" method="post" id="kriteriji">
            
            <%=Html.Label("Izberite vpis") %>
            
            <select name='vpisi' id='vpisi'>
            <option value='prazen'>Izberite vpis</option>
            <%
                for (int i = 0; i < ((List<Vpisi>)ViewData["vpisi"]).Count; i++)
                {
                    Response.Write("<option value='" + ((List<Vpisi>)ViewData["vpisi"])[i].idVpisa + "'>" + ((List<Vpisi>)ViewData["vpisi"])[i].letoVpisa.Year + "/" + (((List<Vpisi>)ViewData["vpisi"])[i].letoVpisa.Year + 1) + " " + ((List<Vpisi>)ViewData["vpisi"])[i].LetnikiStudija.opisLetnika + ".letnik " + ((List<Vpisi>)ViewData["vpisi"])[i].SSmeri.imeSmer + " " + ((List<Vpisi>)ViewData["vpisi"])[i].VrsteVpisa.idVrstaVpisa + "</option>");
                }
           
           
            %>
            
            </select>
            <%=Html.Label("Izberite predmet") %>
            <select name='predmeti' id='predmeti'>
                <option value='prazen'>Izberite predmet</option>
            </select>

            <%=Html.Label("Izberite rok") %>
            <select name='roki' id='roki'>
                <option value='prazen'>Izberite rok</option>
            </select>
            
            <p>
                <input type="submit" value="Prijavi se" class="button" />
            </p>

</form>

</asp:Content>



